﻿<Window x:Class="Mskold.IterationManager.NewIteration"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:Mskold.IterationManager"
        Title="Create New Iteration" Height="475" Width="584" xmlns:my="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.10.0" ResizeMode="CanResize" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" Cursor="Arrow">
    <Window.DataContext >
        <vm:NewIterationViewModel />
    </Window.DataContext>
    <Window.Resources>


        <HierarchicalDataTemplate x:Key="NodeTemplate">
            <!--<TreeViewItem x:Name="tvNode" Header ="{Binding XPath=@Name}" IsHitTestVisible="True" IsTabStop="True" IsSelected="{Binding XPath=@IsSelected, Mode=TwoWay}" Focusable="True"/>-->
            <Label Name="tvNode" Content="{Binding XPath=@Name}" Padding="2" />

            <HierarchicalDataTemplate.ItemsSource>
                <Binding XPath="child::*/child::Node" />
            </HierarchicalDataTemplate.ItemsSource>
            <HierarchicalDataTemplate.Triggers>
                

                <DataTrigger Binding="{Binding  XPath=@Name}"  Value="INSERT NEW ITERATION">
                    <Setter TargetName="tvNode" Property="BorderBrush" Value="Red"/>
                    <Setter TargetName="tvNode" Property="BorderThickness" Value="1"/>
                    <Setter TargetName="tvNode" Property="FontWeight" Value="Bold" />

                </DataTrigger>


            </HierarchicalDataTemplate.Triggers>
        </HierarchicalDataTemplate>

        <Style TargetType="{x:Type Image}" x:Key="toolbarImageStyle">
            <Style.Resources></Style.Resources>
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                    <Setter Property="Opacity" Value="0.50"></Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style TargetType="{x:Type ListItem}" x:Key="insertMark">
                <Setter Property="Background" Value="Red"/>
        </Style>
        
        <my:BooleanToHiddenVisibilityConverter x:Key="BooleanToHiddenVisibilityConverter" />
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
    </Window.Resources>
    <Grid>
        <StackPanel Height="100" HorizontalAlignment="Right" Margin="0,17,12,0" Name="stackPanel1" VerticalAlignment="Top"  >
            <Button Content="Create Iteration" Height="23" HorizontalAlignment="Right" Name="cmdCreateIteration" VerticalAlignment="Top" Width="116" Click="cmdCreateIteration_Click" Margin="5" />
            <Button Content="Cancel" Height="23" HorizontalAlignment="Right"  Name="cmdCancel" VerticalAlignment="Top" Width="116" Click="cmdCancel_Click" Margin="5" />
            <Button Content="Settings..." Height="23" HorizontalAlignment="Right"  Name="cmdSettings" VerticalAlignment="Top" Width="116" Click="cmdSettings_Click" Margin="5" />
        </StackPanel>
        <Grid  Name="grdLayout"  HorizontalAlignment="Stretch" Margin="10,18,150,0" VerticalAlignment="Stretch" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="123"  />
                <ColumnDefinition Width="184*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Label Content="New iteration: " Height="28" HorizontalAlignment="Left"  Name="label1" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1" Padding="5" />
            <TextBox Height="23" HorizontalAlignment="Left"  Name="txtIterationName" VerticalAlignment="Top" Width="254" Grid.Column="1" Grid.Row="1" Text="{Binding Path=IterationName, Mode=TwoWay}" />

            <Label Content="Period:"    Height="Auto" HorizontalAlignment="Left" Name="label2" VerticalAlignment="Top" Grid.Row="2" Width="79" Visibility="{Binding Path=Config.ConfigStore.CreateSprintWorkItem, Converter={StaticResource BooleanToVisibilityConverter1}}" Padding="5" />
            <TextBox Height="23" HorizontalAlignment="Left"  Name="txtStartDate" VerticalAlignment="Top" Width="82" Text="{Binding Path=StartDate, StringFormat=\{0:d\}}" Grid.Column="1" Grid.Row="2" Visibility="{Binding Path=Config.ConfigStore.CreateSprintWorkItem, Converter={StaticResource BooleanToVisibilityConverter1}}" />
            <TextBox Height="23" HorizontalAlignment="Left" Name="txtEndDate"  Margin="100,0,0,0 " VerticalAlignment="Top" Width="95" Text="{Binding Path=FinishDate, StringFormat=\{0:d\}}" Grid.Column="1" Grid.Row="2" Visibility="{Binding Path=Config.ConfigStore.CreateSprintWorkItem, Converter={StaticResource BooleanToVisibilityConverter1}}" />

            <Label Content="Place of the Iteration : "  Height="29" HorizontalAlignment="Left" Name="lblPlacering" VerticalAlignment="Top" Grid.Row="3" />
            <Grid  HorizontalAlignment="Stretch" Name="grid1" VerticalAlignment="Stretch"  Grid.Column="1" Grid.Row="3" Grid.RowSpan="2"> 
                <ToolBarTray Height="33" HorizontalAlignment="Left" Name="toolBarTray1" VerticalAlignment="Top" Width="227"  ToolBar.OverflowMode="Never">
                    <ToolBar Height="32" HorizontalAlignment="Stretch" Margin="0,0 ,0,0" Name="toolbarTreeView" VerticalAlignment="Top"  Width="260"  ToolBarTray.IsLocked="True" ToolBar.OverflowMode="Never" Loaded="ToolBar_Loaded">
                        <Button Name="cmdUp" Click="cmdUp_Click" ToolTip="Up" >
                            <Image Source="/IterationManager;component/Resources/Up.bmp" Height="24" Width="24" Style="{StaticResource toolbarImageStyle}"  />
                        </Button>
                        <Button Name="cmdDown" Click="cmdDown_Click" ToolTip="Down" Grid.Column="1" >
                            <Image Source="/IterationManager;component/Resources/Down.bmp" Height="24" Width="24" Style="{StaticResource toolbarImageStyle}" />
                        </Button>
                        <Button Name="cmdIndent" Click="cmdIndent_Click" ToolTip="Indent" Grid.Column="2" >
                            <Image Source="/IterationManager;component/Resources/Indent.bmp" Height="24" Width="24" Style="{StaticResource toolbarImageStyle}" />
                        </Button>
                        <Button Name="cmdOutDent" Click="cmdOutDent_Click" ToolTip="Outdent" Grid.Column="3" >
                            <Image Source="/IterationManager;component/Resources/OutDent.bmp" Height="24" Width="24" Style="{StaticResource toolbarImageStyle}" />
                        </Button>
                    </ToolBar>
                </ToolBarTray>
                <TreeView Margin="0,34,0,0" HorizontalAlignment="Stretch" Name="treeView2" VerticalAlignment="Stretch" ItemsSource="{Binding Path=Iterations.FirstChild}" ItemTemplate="{StaticResource NodeTemplate}" SelectedItemChanged="treeView2_SelectedItemChanged" SelectedValuePath="&quot;NodeId&quot;">
                    <TreeView.ItemContainerStyle>
                        <Style TargetType="{x:Type TreeViewItem}">
                            <Setter Property="IsExpanded" Value="True" />
                            <!--<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />-->

                            <EventSetter Event="TreeViewItem.DragOver" Handler="treeView1_DragOver"/>
                            <EventSetter Event="TreeViewItem.Drop" Handler="treeView1_Drop"/>
                            <EventSetter Event="TreeViewItem.MouseMove" Handler="treeView1_MouseMove"/>
                            <Style.Triggers>
                                
                            </Style.Triggers>

                        </Style>
                    </TreeView.ItemContainerStyle>
                </TreeView>
            </Grid>
            <Label Content="Actions:" Height="28" HorizontalAlignment="Left"  Name="label3" VerticalAlignment="Top" Grid.Row="5"/>
            <ListBox Grid.Column="1" Grid.Row="5" Height="75    " HorizontalAlignment="Left" Margin="0,4,0,0" Name="listBox1" VerticalAlignment="Top" ItemsSource="{Binding Path=ActionTitles}" ToolTip="Actions to be taken"  IsEnabled="True" BorderBrush="{x:Null}" Background="{x:Null}" SelectionMode="Extended" MaxHeight="50" />
        </Grid>
        
    </Grid>
</Window>
